﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace FluentHtmlHelpers.Controllers
{
    public class ValuesController : ApiController
    {

        private static List<string> data= new List<string>(); 
        // GET api/values
        public IEnumerable<string> Get()
        {
            return data;
        }

        // GET api/values/5
        public HttpResponseMessage Get(int id)
        {
            if (id <data.Count)
            {
                return Request.CreateResponse(HttpStatusCode.OK, data[id]);
            }
            return Request.CreateResponse(HttpStatusCode.NotFound, "Item not Found");
        }

        // POST api/values
        public HttpResponseMessage Post([FromBody]string value)
        {
            data.Add(value);
            var message = Request.CreateResponse(HttpStatusCode.Created);
            message.Headers.Location = new Uri(Request.RequestUri, (data.Count - 1).ToString());
            return message;
        }

        // PUT api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }
}
